﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WFNetLib.GDI;
using System.Web.Security;

namespace CarBlackBox
{
    public partial class Form_Main : Form
    {
        public static string Operator="wangf0228";
        private Form form;
        public Form_Main()
        {
            InitializeComponent();
//             Rectangle rect = SystemInformation.VirtualScreen;
//             Bitmap bt = new Bitmap(rect.Width, rect.Height);
//             ImageFillRect.Image_FillRect(new Bitmap(this.BackgroundImage), bt, FillMode.Struk);
//             this.BackgroundImage = bt;
        }
        public Form_Main(string adminname, Form f)
        {
            InitializeComponent();
            form = f;            
//             Rectangle rect = SystemInformation.VirtualScreen;
//             Bitmap bt = new Bitmap(rect.Width, rect.Height);
//             ImageFillRect.Image_FillRect(new Bitmap(this.BackgroundImage), bt, FillMode.Struk);
//             this.BackgroundImage = bt;
            Operator = adminname;
        }

        private void Form_Main_SizeChanged(object sender, EventArgs e)
        {

        }

        private void Form_Main_Load(object sender, EventArgs e)
        {
            WFNetLib.Log.SystemLogData.DefaultOperator = Operator;
        }

        private void Form_Main_MaximumSizeChanged(object sender, EventArgs e)
        {

        }

        private void Form_Main_FormClosed(object sender, FormClosedEventArgs e)
        {
            MessageBox.Show("护照存取管理系统已经正常退出，感谢您的使用，祝您工作顺利！！");            
            Application.Exit();
            //form.Close();
        }

        private void pbClose_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要退去本系统吗？", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                this.Close();
        }

        private void pbDrivingLog_Click(object sender, EventArgs e)
        {
            Form_DrivingLog f = new Form_DrivingLog();
            f.ShowDialog();
        }

        private void pbDriverManage_Click(object sender, EventArgs e)
        {
            Form_DriverManage f = new Form_DriverManage();
            f.ShowDialog();
        }

        private void ptVehicleManage_Click(object sender, EventArgs e)
        {
            Form_VehicleManage f = new Form_VehicleManage();
            f.ShowDialog();
        }

        private void ptDataConllection_Click(object sender, EventArgs e)
        {
            Form_DataConllection f = new Form_DataConllection();
            f.ShowDialog();
        }

        private void ptUserManage_Click(object sender, EventArgs e)
        {
            Form_UserManage f = new Form_UserManage();
            f.ShowDialog();
        }

        private void ptChangePassword_Click(object sender, EventArgs e)
        {
            Form_ChangePassword f = new Form_ChangePassword();
            f.ShowDialog();
        }

        private void pbSystemLog_Click(object sender, EventArgs e)
        {
//             public Form_LogShow_Normal(string[] Types,bool bDelete)
//         {
//             InitializeComponent();
//             cbType.Items.Add("全部");
//             cbType.Items.AddRange(Types);
//             cbType.SelectedIndex = 0;
//         }
            bool bDelete = Roles.IsUserInRole(Operator, ROLES.日志管理.ToString());
            WFNetLib.Log.Form_LogShow_Normal f = new WFNetLib.Log.Form_LogShow_Normal(Enum.GetNames(typeof(LogType)), bDelete);
            f.ShowDialog();
        }

        private void pbProductManage_Click(object sender, EventArgs e)
        {
            Form_ProductManage f = new Form_ProductManage();
            f.ShowDialog();
        }

        private void pbtSystemOption_Click(object sender, EventArgs e)
        {
            Form_SystemOption f = new Form_SystemOption();
            f.ShowDialog();
        }

        private void pbDriverTrack_Click(object sender, EventArgs e)
        {
            if(Roles.IsUserInRole(Operator,ROLES.行驶轨迹.ToString()))
            {
                Form_DriverTrack f = new Form_DriverTrack();
                f.ShowDialog();
            }
        }
    }
}
